<?
include_once("activerecode.php");

class wdms_aa_rel extends ActiveRecode {
		var ono;
	var pno;
	var ano;
	var weight;
	var fields;
	var fields_name_collection;



		function wdms_aa_rel($id = -1) {
		 
		$this->ono = $id;
		$i = 0;
		$this->tablename = "wdms_aa_rel";
		$datas = array();
		if($id > 0)
		{
			$this->fields_name_collection = array();
			$datas = $this->select_("ono", $id);			$this->fields[ono] = $datas['ono'];
			$this->fields_name_collection[] = "ono";
			$this->fields[pno] = $datas['pno'];
			$this->fields_name_collection[] = "pno";
			$this->fields[ano] = $datas['ano'];
			$this->fields_name_collection[] = "ano";
			$this->fields[weight] = $datas['weight'];
			$this->fields_name_collection[] = "weight";

		}
	}

	function save() {
		
		//update
		$id = $this->fields[\$this->fields_name_collection[0]];
		if($id > 0)
		{
			$this->update_($this->fields, $this->fields_name_collection[0]." = ".$id);
		}
		else	//insert
		{
			$this->insert_($this->fields);
		}
		
	}

	function destroy($id = -1) {
		
		if($id > 0)
		{
			$this->delete_($this->fields_name_collection[0]." = ".$id);
		}
		else
		{
			$id = $this->fields[$this->fields_name_collection[0]];
			$this->delete_($this->fields_name_collection[0]." = ".$id);
		}
		
	}

	function find_by_ono($index) {
		
		$id = $this->fields[$this->fields_name_collection[0]];
		$datas = $this->select_("ono", $index);$this->fields['ono'] = $datas['ono'];$this->fields['pno'] = $datas['pno'];$this->fields['ano'] = $datas['ano'];$this->fields['weight'] = $datas['weight'];
	}

	function find_by_pno($index) {
		
		$id = $this->fields[$this->fields_name_collection[0]];
		$datas = $this->select_("pno", $index);$this->fields['ono'] = $datas['ono'];$this->fields['pno'] = $datas['pno'];$this->fields['ano'] = $datas['ano'];$this->fields['weight'] = $datas['weight'];
	}

	function find_by_ano($index) {
		
		$id = $this->fields[$this->fields_name_collection[0]];
		$datas = $this->select_("ano", $index);$this->fields['ono'] = $datas['ono'];$this->fields['pno'] = $datas['pno'];$this->fields['ano'] = $datas['ano'];$this->fields['weight'] = $datas['weight'];
	}

	function find_by_weight($index) {
		
		$id = $this->fields[$this->fields_name_collection[0]];
		$datas = $this->select_("weight", $index);$this->fields['ono'] = $datas['ono'];$this->fields['pno'] = $datas['pno'];$this->fields['ano'] = $datas['ano'];$this->fields['weight'] = $datas['weight'];
	}



}
?>
